﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using Code.Models;
using System.Web.Mvc;
using Code.BLL;

namespace QianBuo.Lottery.Web.Areas.Manage.Models
{
    public class SchemeModels
    {
        [Serializable]
        public class SchemeModel
        {
            public SchemeModel()
            {
                Serch = new SchemeManage.SchemeSerchModel();
                var selectitems = CacheManage.Lottery.Where(p => p.Value.State != (short)LotteryState.Locked).OrderBy(p=>p.Value.ID).OrderBy(p=>p.Value.Sort)
                .Select(p => new SelectListItem { Text = p.Value.Name, Value = p.Key.ToString() }).ToList();
                selectitems.Insert(0, new SelectListItem { Text = "所有彩种", Value = string.Empty });
                LotteryTypes = selectitems;
                selectitems = CacheManage.Ratio.Where(p => p.Value.State != (short)ConsumeRatioState.Locked)
                    .Select(p => new SelectListItem { Text = p.Value.Name, Value = ((double)p.Value.Ratio).ToString() }).ToList();
                selectitems.Insert(0, new SelectListItem { Text = "所有", Value = string.Empty });
                Ratios = selectitems;
                selectitems = CacheManage.WinModel.Where(p => p.Value.State != (short)WinMoneyModelState.Locked)
                    .Select(p => new SelectListItem { Text = p.Value.Name, Value = p.Value.ID.ToString() }).ToList();
                selectitems.Insert(0, new SelectListItem { Text = "所有", Value = string.Empty });
                WinModels = selectitems;
                selectitems = (Enum.GetValues(typeof(SchemeState)) as SchemeState[]).Select(p => new SelectListItem { Text = p.GetName(), Value = p.ToString() }).ToList();
                selectitems.Insert(0, new SelectListItem { Text = "所有", Value = string.Empty });
                States = selectitems;
                IsChaseTasks = new SelectListItem[] { new SelectListItem { Text = "所有",Value=string.Empty }, new SelectListItem { Text = "是", Value = "True" }, new SelectListItem { Text = "否", Value = "False" } };
                Page = 1;
                PageSize = CacheManage.OptionSite[Option_Site_Key.Site_PageInfo_PageCount].ToInt32(15);;
            }
            public IEnumerable<SchemeManage.SchemeItemModel> Schemes { get; set; }
            public SchemeManage.SchemeItemModel SumSchems { get; set; }
            [Required]
            public SchemeManage.SchemeSerchModel Serch { get; set; }
            public IEnumerable<SelectListItem> LotteryTypes { get; set; }
            public IEnumerable<SelectListItem> States { get; set; }
            public IEnumerable<SelectListItem> Ratios { get; set; }
            public IEnumerable<SelectListItem> WinModels { get; set; }
            public IEnumerable<SelectListItem> IsChaseTasks { get; set; }
            public int SumCount { get; set; }
            [Range(1,999999999)]
            public int PageSize { get; set; }
            [Range(1,999999999)]
            public int Page { get; set; }
        }
        [Serializable]
        public class DetailModel
        {
            public SchemeManage.SchemeItemModel Scheme { get; set; }
            public IEnumerable<SchemeManage.SchemePlayModel> Plays { get; set; }
            public IEnumerable<SchemeManage.SchemeWinMoneyModel> WinMoneys { get; set; }
            /// <summary>
            /// 追号详情列表
            /// </summary>
            public IEnumerable<ChaseManage.ChaseTaskDetailItem> ChaseTaskDetailList { get; set; }
        }
    }
}